
//  NavViewController.m
//  TestDemo
//
//  Created by yutao on 14-2-18.
//  Copyright (c) 2014年 yutao. All rights reserved.
//

#import "NavViewController.h"
#import "Question.h"
#import "MyTaskOperation.h"

@interface NavViewController ()

@end

@implementation NavViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    
//    Question *question=[[Question alloc] init];
//    Question *ques=[Question new];
     
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void) methodA{
    
    NSLog(@"成功执行methodA方法");
}

-(void) methodARequire:(NSString *)value{
    NSLog(@"methodARequire%@",value);
}

-(void) callBack{
    
}


-(IBAction) BackClick:(id)sender{
    
    NSLog(@"BackClick");
    [self dismissViewControllerAnimated:YES completion:nil];
    
}

-(IBAction) JumpTabbarClick:(id)sender{
    NSLog(@"JumpTabbarClick");
    if(self.tabBarController==nil){
        self.tabBarController=(MyTabBarController*)[[[NSBundle mainBundle]loadNibNamed:@"MyTabBarController" owner:nil options:nil] objectAtIndex:0];
        //self.tabBarController=[[MyTabBarController alloc] init];
    }
    [self.tabBarController setSelectedIndex:0];
    [self presentViewController:self.tabBarController animated:YES completion:nil];
    
}


-(IBAction) OneClick:(id)sender{
    NSLog(@"OneClick");
    if( self.progressView.progress<1.0f){
        self.progressView.progress+=0.2f;
    }
    
    
}


//两种启动线程的方法
-(IBAction) TwoClick:(id)sender{
    NSThread *thread=[[NSThread alloc] initWithTarget:self selector:@selector(doInBackground) object:nil];
    [thread start];
    
}

-(void) doInBackground{
    NSLog(@"doInBackground");
}

-(IBAction) ThreeClick:(id)sender{
    [NSThread detachNewThreadSelector:@selector(doInBackground2) toTarget:self withObject:nil];
    
}

-(void) doInBackground2{
    NSLog(@"doInBackground2");
    [self doTaskOperation];
}


//多线程队列实现
-(void) doTaskOperation{
    NSOperationQueue *operationQueue=[[NSOperationQueue alloc] init];
    for(int i=0;i<5;i++){
        MyTaskOperation *myTask=[[MyTaskOperation alloc] init];
        myTask.index=i;
        [operationQueue addOperation:myTask];
    }
   
    
}

@end
